import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:26554
 * Date:2024-10-30
 * Time:23:26
 */
public class text {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int num = scan.nextInt();
        int count = 0;
        while (num!=0) {
           if(num>9&&num%10==9){
                   num/=10;
                   count++;
           }else if(num==9){
                   count++;
                   num/=10;

           }
        }
        System.out.println(count);
    }
}
